import request from '@/utils/request'

const base_api = '/admin/system/sysRole'

// 分页查询角色列表
export const GetSysRoleListByPage = (page, pageSize, queryDto) => {
  return request({
    url: `${base_api}/findByPage/${page}/${pageSize}`,
    method: 'post',
    data: queryDto,
  })
}

// // 添加角色(这种格式不推荐)
// export const SaveSysRole = sysRole => {
//   return request.post(`${base_api}/saveSysRole`, sysRole)
// }

// 添加角色(这种格式推荐)
export const SaveSysRole = sysRole => {
  return request({
    url: `${base_api}/saveSysRole`,
    method: 'post',
    data: sysRole,
  })
}

// 修改角色
export const UpdateSysRole = sysRole => {
  return request({
    url: `${base_api}/updateSysRole`,
    method: 'put',
    data: sysRole,
  })
}

// 删除角色
export const DeleteSysRoleById = roleId => {
  return request({
    url: `${base_api}/deleteSysRoleById/${roleId}`,
    method: 'delete',
  })
}

// 查询全部角色
export const FindAllSysRoleList = userId => {
  return request({
    url: `${base_api}/findAllSysRole/${userId}`,
    method: 'get',
  })
}

// 查询指定角色所对应的菜单id
export const GetSysRoleMenuIds = roleId => {
  return request({
    url: '/admin/system/sysRoleMenu/findSysRoleMenuByRoleId/' + roleId,
    method: 'get',
  })
}

// 根据角色分配菜单请求方法
export const DoAssignMenuIdToSysRole = assignMenuDto => {
  return request({
    url: '/admin/system/sysRoleMenu/doAssign',
    method: 'post',
    data: assignMenuDto,
  })
}
